import axios from '../http';
import { HttpResponse } from '@/types/HttpResponse';
/**
 * @interface deleteParams -删除参数
 * @property {string} orderID -订单号
 */
export interface deleteParams {
  orderID: number;
}
/**
 * @interface getMyOrder
 */
interface getMyOrder {}
//封装接口方法

/**
 * @description 订单相关
 *
 * @return {HttpResponse} result
 */
export class Order {
  /**
   * @description 提交订单
   *
   * @return {HttpResponse} result
   */
  static async sendOrder(data: Object): Promise<HttpResponse> {
    return axios('/addOrder', {
      method: 'post',
      responseType: 'json',
      data: data,
    });
  }
  /**
   * @description 删除订单
   *
   * @return {HttpResponse} result
   */
  static async deleteOrder(params: deleteParams): Promise<HttpResponse> {
    return axios('/deleteOrder', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }

  /**
   * @description 更改订单信息
   * @param data
   * @returns {HttpResponse} result
   */
  static async setOrder(data: {
    orderId: string;
    seats: string[];
  }): Promise<HttpResponse> {
    return axios('/setOrder', {
      method: 'post',
      responseType: 'json',
      data: data,
    });
  }

  /**
   * @description 返回所有订单
   *
   * @return {HttpResponse} result
   */
  static async getMyorder(): Promise<HttpResponse> {
    return axios('/getMyOrder', {
      method: 'get',
      responseType: 'json',
    });
  }

  /**
   * @description 获取订单信息
   * @param params
   * @returns {HttpResponse} result
   */
  static async getOrder(params: { orderId: string }): Promise<HttpResponse> {
    return axios('/getOrder', {
      method: 'get',
      responseType: 'json',
      params: params,
    });
  }

  /**
   * @description 选座
   * @param data
   * @returns {HttpResponse} result
   */
  static async selectSeat(data: {
    orderId: string;
    seats: string[];
  }): Promise<HttpResponse> {
    return axios('/selectSeat', {
      method: 'post',
      responseType: 'json',
      data: data,
    });
  }
}
